package com.ytjj.qmyx.admin.controller;

import com.ytjj.common.api.CommonResult;
import com.ytjj.qmyx.admin.model.request.EvaluationRequest;
import com.ytjj.qmyx.admin.service.EvaluationProductImgService;
import com.ytjj.qmyx.mall.model.EvaluationProductImg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 *
 *
 * @Version: 1.0
 */
@RestController
@RequestMapping("/evaluationImg")
public class EvaluationImgController {

    @Autowired
    private EvaluationProductImgService evaluationProductImgService;

    @PostMapping("/list")
    public CommonResult getImgList(@RequestBody EvaluationRequest evaluationRequest) {
        return CommonResult.success(evaluationProductImgService.getImgList(evaluationRequest));
    }

    @PostMapping("/updateImg")
    public CommonResult updateImg(@RequestBody EvaluationProductImg evaluationProductImg) {
        Integer count = evaluationProductImgService.updateImg(evaluationProductImg);
        if(count > 0) {
            return CommonResult.success(count);
        } else {
            return CommonResult.failed();
        }
    }

    @GetMapping("/updateStatus")
    public CommonResult updateStatus(@RequestParam Integer id) {
        Integer count = evaluationProductImgService.updateStatus(id);
        if(count > 0) {
            return CommonResult.success(count);
        } else {
            return CommonResult.failed();
        }
    }

}
